import java.util.*;
public class _12151{
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        long[] a=new long[100000];
        int t= sc.nextInt();
        for(int r=0;r<t;r++){
            int n=sc.nextInt();
            long min=1000000000000000000l;
            for(int i=0;i<n;i++){
                a[i] = sc.nextLong();
                if(a[i]<min&&a[i]>1){
                    min=a[i];
                }
            }
            long all=0L;
            for(int i=0;i<n;i++){
                if(a[i]==1||a[i]==min){
                    continue;
                }else if(a[i]%min==0){
                }else if(a[i]==0){
                    break;
                }else
                all+=fuck(a[i],min);
            }
            System.out.println(all);
            //System.out.println(Arrays.toString(a));
            for(int i=0;i<n;i++){
                if(a[i]==1||a[i]==min){
                    continue;
                }else if(a[i]%min==0){
                }else if(a[i]==0){
                    break;
                }else
                    fuckyou(a[i],min,i+1);
            }
        }
    }
    public static long fuck(long a,long min){
        long count=0L;
        int i=0;
        long end= min;
        while(end<a){
           end= (min*(int)Math.pow(2,i++));
        }
        while(a<end){
            a=a*2;
            count++;
        }
        return count;
    }
    public static void fuckyou(long a,long min,int c){
        int i=0;
        long end=min;
        while(end<a){
            end= (min*(int)Math.pow(2,i++));
        }
        while(a<end){
            if(a*2<end){
                System.out.println(c+" "+a);
                a=a*2;
            }else {
                System.out.println(c+" "+(end-a));
                a=a*2;
            }
            
        }
    }
}